#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#define USER "USER"

#define MY_ENV "myval"
#define MYPWD "PWD"
int main(int argc,char* argv[],char* env[])//命令行选项
{

  extern char** environ;
  for(int i=0;environ[i];i++)
  {
    printf("env[%d]:%s\n",i,environ[i]);
  }

  for(int i=0;env[i];i++)
  {
    printf("env[%d]:%s\n",i,env[i]);
  }


  if(argc!=2)
  {
    printf("Usage:\n\t%s [-a/-b/-c/-ab/-ac/-bc/-abc]\n",argv[0]);
    return 1;
  }
  if(strcmp("-a",argv[1])==0)
  {
    printf("功能a\n");
  }

  if(strcmp("-b",argv[1])==0)
  {
    printf("功能b\n");
  }

  if(strcmp("-c",argv[1])==0)
  {
    printf("功能c\n");
  }
  if(strcmp("-ab",argv[1])==0)
  {
    printf("功能ab\n");
  }
  if(strcmp("-ac",argv[1])==0)
  {
    printf("功能ac\n");
  }
  if(strcmp("-bc",argv[1])==0)
  {
    printf("功能bc\n");
  }
  //printf("%s\n",getenv(MYPWD));
  //char* myenv=getenv(MY_ENV);
  //if(NULL == myenv)
  //{
  //  printf("%s,not found\n",MY_ENV);
  ///  return 1;
  //}
  //printf("%s=%s\n",MY_ENV,myenv);
  //char* who=getenv("USER");
  //if(strcmp(who,"root")==0)
  //{
  //  printf("user:%s\n",who);
  //  printf("user:%s\n",who);
  //  printf("user:%s\n",who);
  //  printf("user:%s\n",who);
  //  printf("user:%s\n",who);
  //}
  //else{
  //  printf("权限不足！\n");
  //}
  return 0;
}
